﻿@{
    ViewBag.Title = "JKHistory";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var listColumns = ViewBag.Columns as List<SGArchiveSystem7x.Models.CColumnsModel>;
    var listArchiveTree = ViewBag.ArchiveTree as List<SGArchiveSystem7xDB.T_ArchiveTree>;
}

<table id="grid" class="easyui-datagrid" style="width:100%;" title="@ViewBag.NAME" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:false,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Insiders_BrrHistory_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead frozen="true">
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
    <thead>
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (!c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
</table>
<div id="Insiders_BrrHistory_tb" style="padding:2px 5px;">
    <select id="Insiders_BrrHistory_cmbArchiveTree" class="easyui-combobox" labelposition="right" label="@ViewBag.Text0" labelwidth="80px" labelalign="right" data-options="editable:false" name="cmbType" style="width:170px;" panelHeight="auto" editable="false">
        @{
        if (SGArchiveSystem7x.Models.Language._nowLanguage == SGArchiveSystem7xDB._VersionLanguage._Chs)
        {
            <option value="-1">全部</option>
        }
        else
        {
            <option value="-1">ALL</option>
        }
        }
        @{
        foreach (SGArchiveSystem7xDB.T_ArchiveTree n in ViewBag.ArchiveTree)
        {
            <option value="@n.AR_NAME">@n.AR_NAME</option>
        }
        }
    </select>
    <input type="text" class="easyui-textbox pull-left" label="@ViewBag.Text1" labelwidth="80px" labelalign="right" style="width:180px" id="txtDH" />
    <input type="text" class="easyui-textbox pull-left" label="@ViewBag.Text2" labelwidth="80px" labelalign="right" style="width:180px" id="txtFTM" />
    <input type="text" class="easyui-textbox pull-left" label="@ViewBag.Text3" labelwidth="80px" labelalign="right" style="width:180px" id="txtTM" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="@ViewBag.Text4" labelwidth="110px" labelalign="right" style="width:220px" id="txtSTime" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="@ViewBag.Text5" labelwidth="110px" labelalign="right" style="width:220px" id="txtETime" />
    <a href="javascript:void(0);" class="easyui-linkbutton button-blue" iconCls="icon-search" onclick="QUERY()" style="height: 30px;width:110px">@ViewBag.Text6</a>
    <a href="javascript:void(0);" class="easyui-linkbutton button-blue" iconCls="icon-print" onclick="TOXLS()" style="height: 30px;width:110px">@ViewBag.Text7</a>
</div>
<script>
    $(document).ready(function () {
        $('#grid').datagrid({
            url: '/LogBorrow/Get_ajaxJKHistory?type=1',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
        InitPagenation();
    });


    function SearchPager(num, size) {

        $('#grid').datagrid('options').url = '/LogBorrow/Get_ajaxJKHistoryPager?num=' + num +
            '&size=' + size + '&type=1';
        $('#grid').datagrid('reload');
        $('#grid').datagrid('options').pageNumber = num;
        $('#grid').datagrid('options').pageSize = size;
    }


    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                SearchPager(pageNumber, pageSize);
            }
        });
    }
    function QUERY() {
        var nd = '';
        var ftm = $('#txtFTM').val();
        var dh = $('#txtDH').val();
        var tm = $('#txtTM').val();
        var type = $('#Insiders_BrrHistory_cmbArchiveTree').combobox('getValue');
        var stime = $('#txtSTime').datebox('getValue');
        var etime = $('#txtETime').datebox('getValue');
        //arname, dh, tm, nd,sd, ed,
        $('#grid').datagrid('options').url = '/LogBorrow/Get_ajaxJKHistory?arname=' + type + '&dh=' + dh + '&tm=' + tm + '&nd=' + nd + '&sd=' + stime + '&ed=' + etime + '&type=1&ftm=' + ftm;
        $('#grid').datagrid('load');
    }
    function formatDate(value, row) {
        if (value != null) {
            var time = new Date(parseInt(value.substr(6, 19)))//.toLocaleDateString();//13
            var month = (time.getMonth() + 1);
            if (month < 9)
                month = "0" + month;
            var day = time.getDate();
            if (day < 9)
                day = "0" + day;

            var hm = '';
            var hours = time.getHours(); var mint = time.getMinutes();
            if (hours == 0 && mint == 0)
                hm = '';
            else {
                if (hours < 9)
                    hours = "0" + hours;
                if (mint < 9)
                    mint = "0" + mint;

                hm = hours + ":" + mint;
            }


            return time.getFullYear() + "-" + month + "-" + day + " " + hm; ///+ ":" + time.getSeconds();
        }
        else {
            return "";
        }
    }


    function InitPagenation() {
        //设置分页控件
        var p = $('#grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                QueryPager(pageNumber, pageSize);
            }
        });
    }
    ///分页查询
    function QueryPager(num, size) {
        $('#grid').datagrid('options').url = '/LogBorrow/Get_ajaxJKHistoryPager?num=' + num + '&size=' + size + '&type=1';
        $('#grid').datagrid('reload');
        $('#grid').datagrid('options').pageNumber = num;
        $('#grid').datagrid('options').pageSize = size;
        return;
    }

    function TOXLS() {
        //DownLoadxls
        $.ajax({
            url: '/LogBorrow/DownLoadxls?type=1',
            type: 'post',
            dataType: "text",
            success: function (data) {
                if (data != '')
                    window.open(data);
                //var tdn = document.getElementById('Main_Index_myInfo');
                //tdn.innerHTML = data;
            }
        });
    }
</script>


